#-*- coding: utf8 -*-
from tutor.script import *
from tutor.plugin.maple import *

# variáveis úteis
half = M('1/2')
t = M.t
_i, _j, _k = M('_i, _j, _k')
rr = M('`..`')
coeff, sqrt = M.coeff, M.sqrt
r = M.r
t = M.t

# parâmetros iniciais
R = oneof(1, M.sqrt(2), 2, M.sqrt(3), M.sqrt(6))
a = R**2
zeq = a - x**2 - y**2
cone = sqrt(x**2 + y**2)
print('parabola_eq:', zeq)

# superficie superior
fx = diff(zeq, x)
fy = diff(zeq, y)
JS = sqrt(fx**2 + fy**2 + 1)

# integral de superfície
aux = subs(x==r*cos(t), y==r*sin(t), JS)
cima = M.simplify(M.int(M.int(aux * r, r=rr(0, R)), t=rr(0, 2*Pi)))
area = cima + Pi * 2 * R**2
print('area:', area)
print('cima:', cima)

aux = subs(x==r*cos(t), y==r*sin(t), JS)
jacob = M.simplify(M.int(M.int(aux * r, r=rr(0, R)), t=rr(0, 2*Pi)))
jacob += Pi * 4 * R
print('jacob:', jacob)

aux = subs(x==r*cos(t), y==r*sin(t), (1 + fx + fy))
soma = M.simplify(M.int(M.int(aux * r, r=rr(0, R)), t=rr(0, 2*Pi)))
soma += Pi * 2 * R**2
print('soma:', soma)

# TODO: volume

